<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>移动端事件</title>
    <style>
        *{margin: 0;padding:0;box-sizing: border-box}
        #banner{
            width: 100%;
            height: 300px;
            border:solid 1px #666;
        }

        #box{
            width: 200px;
            height: 200px;
            border:solid 1px #000;
        }

    </style>
</head>
<body>
    <div id="banner">

    </div>

    <script>
        //获取元素
        let banner = document.querySelector("#banner");

        //绑定事件
        banner.addEventListener('touchstart', function(e){
            //手指按下的位置
            //事件触发后, 事件源身上的触点个数
            banner.innerHTML = "事件源上的触点个数: " + e.targetTouches.length;
            banner.innerHTML += "<br>屏幕上的触点个数: " + e.touches.length;
            banner.innerHTML += "<br>同时按下触点个数: " + e.changedTouches.length;
            e.preventDefault();
        });

        banner.addEventListener('touchmove', function(){
            banner.innerHTML = "事件源上的触点个数: " + e.targetTouches.length;
            banner.innerHTML += "<br>屏幕上的触点个数: " + e.touches.length;
            banner.innerHTML += "<br>同时滑动触点个数: " + e.changedTouches.length;
            e.preventDefault();
        });

        banner.addEventListener('touchend', function(e){
            banner.innerHTML = "事件源上的触点个数: " + e.targetTouches.length;
            banner.innerHTML += "<br>屏幕上的触点个数: " + e.touches.length;
            banner.innerHTML += "<br>同时抬起触点个数: " + e.changedTouches.length;
            e.preventDefault();
        });
    </script>
</body>
</html>